#ifndef __M32C0_H__
#define __M32C0_H__

#ifdef __cplusplus
extern "C" {
#endif


/*
 * MIPS32 Exception Codes
 */
#define EXC_INTR    0   /* interrupt */
#define EXC_MOD     1   /* tlb modification */
#define EXC_TLBL    2   /* tlb miss (load/i-fetch) */
#define EXC_TLBS    3   /* tlb miss (store) */
#define EXC_ADEL    4   /* address error (load/i-fetch) */
#define EXC_ADES    5   /* address error (store) */
#define EXC_IBE     6   /* bus error (i-fetch) */
#define EXC_DBE     7   /* data bus error (load/store) */
#define EXC_SYS     8   /* system call */
#define EXC_BP      9   /* breakpoint */
#define EXC_RI      10  /* reserved instruction */
#define EXC_CPU     11  /* coprocessor unusable */
#define EXC_OVF     12  /* integer overflow */
#define EXC_TRAP    13  /* trap exception */
#define EXC_RES14   14
#define EXC_FPE     15  /* floating point exception */
#define EXC_IS1     16  /* implementation-specific 1 */
#define EXC_IS2     17  /* implementation-specific 2 */
#define EXC_C2E     18  /* coprocessor 2 exception */
#define EXC_RES19   19
#define EXC_RES20   20
#define EXC_RES21   21
#define EXC_MDMX    22  /* mdmx unusable */
#define EXC_WATCH   23  /* watchpoint */
#define EXC_MCHECK  24  /* machine check */
#define EXC_THREAD  25  /* thread */
#define EXC_DSPU    26  /* dsp unusable */
#define EXC_RES27   27
#define EXC_RES28   28
#define EXC_RES29   29
#define EXC_RES30   30
#define EXC_RES31   31


#ifndef _ASSEMBLER_

#define _mips_nop() \
  __asm__ __volatile ("%(ssnop%)" : :) 

#define _mips_sync() \
  __asm__ __volatile ("sync" : : : "memory")

/* wait for unmasked interrupt */
#define _mips_wait() \
  __asm__ __volatile ("wait")



/* MIPS32r2 write previous gpr */
#define _mips32r2_wrpgpr(regno, val) \
do { \
    __asm __volatile ("wrpgpr $%0,%z1" \
                  : /* no outputs */ \
              : "JK" (regno), "dJ" (val)); \
} while (0)

/* MIPS32r2 read previous gpr */
#define _mips32r2_rdpgpr(regno) \
__extension__({ \
    reg_t __val; \
    __asm __volatile ("rdpgpr %0,$%1" \
                  : "=d" (__val) \
              : "JK" (regno)); \
    __val; \
})


#endif /* _ASSEMBLER_ */

#ifdef __cplusplus
}
#endif

#endif /* __M32C0_H__ */

